import request from "../../utils/request";

// 获取购物车列表

const getCartList = ()=>{
    return request.get('/api/carts',{params:{include:'goods'}})
}

// 添加购物车

const addCart = (goodsInfo)=>{
    return request.post('/api/carts',{goods_id:goodsInfo.id,num:1})
}

// 购物车数量改变

const changeCartCount = (cart)=>{
    return request.put('/api/carts/' + cart.id,{num:cart.num})
}

// 移除购物车

const deleteCart = (id)=>{
    return request.delete('/api/carts/'+id)
}

// 购物车改变选中

const checkedCart = (cartIds)=>{
    return request.patch('/api/carts/checked',{cart_ids:cartIds})
}
export {
    getCartList,
    addCart,
    changeCartCount,
    deleteCart,
    checkedCart

}